import networkx as nx
import matplotlib.pyplot as plt

data=[
    ('s','v1',{'capacity':8,'weight':2}),
    ('s','v3',{'capacity':7,'weight':8}),
    ('v1','v3',{'capacity':5,'weight':5}),
    ('v1','v2',{'capacity':9,'weight':2}),
    ('v2','v3',{'capacity':2,'weight':1}),
    ('v3','v4',{'capacity':9,'weight':3}),
    ('v4','v2',{'capacity':6,'weight':4}),
    ('v2','t',{'capacity':5,'weight':6}),
    ('v4','t',{'capacity':10,'weight':7})
]
G=nx.DiGraph()
G.add_edges_from(data)
minFlow=nx.max_flow_min_cost(G,'s','t')
mincost=nx.cost_of_flow(G,minFlow)
nx.draw(G,with_labels=True)
plt.show()
print(mincost)